import React, { Component } from 'react';
import './style/index.less';

//引入 文件预览组件  https://blog.csdn.net/weixin_43719566/article/details/100704932
import FileViewer from 'react-file-viewer';


/**
 * 视频播放组件
 */
class Video extends Component {
  static defaultProps = {
    prefixCls: 'antui-video'
  };

  render() {
  /*  return (
      <div>
        
      </div>
    );*/

    let { top, file } = this.state;
    let { play, sonstate } = this.props
    var index = file.lastIndexOf(".");
    var type = file.substr(index + 1);
    return (
        <div>
          <div className="top" style={{ display: play ? 'flex' : 'none' }}>
            <div className="all" >
              <div className="allname">
                <div className="topall"><Button style={{ opacity: '0' }}>关闭</Button><div></div><Button onClick={() => {
                  sonstate(false)
                  this.setState({ top: false, file: '' })
                }}>关闭</Button>
                </div>
                {/* 使用这个组件 */}
                <FileViewer fileType={type}
                            filePath={file}
                            onError={this.onError}
                            errorComponent={Error}
                            unsupportedComponent={Error}
                />
              </div>
            </div>
          </div>
        </div>
    )


  }
}

export default Video;